//
//  HELExamVC.m
//  HandheldELearn
//
//  Created by 陈武琦 on 16/7/21.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "CWQ_collectionSegmentVC.h"
#import "YSLContainerViewController.h"
#import "BTCouseListVC.h"

#import "SegmentViewController.h"

#define MENU_BUTTON_WIDTH   kScreenWidth/2
#define ViewWidth [[UIScreen mainScreen] bounds].size.width
#define ViewHeight [[UIScreen mainScreen] bounds].size.height

static CGFloat const ButtonHeight = 44;


@interface CWQ_collectionSegmentVC ()<YSLContainerViewControllerDelegate>

@property(nonatomic, strong) BTCouseListVC *learnVC;
@property(nonatomic, strong) BTCouseListVC *topicVC;
@property(nonatomic, strong)UIBarButtonItem *deleteBarItem;
@property(nonatomic, strong)UIBarButtonItem *cancelBarItem;

@end

@implementation CWQ_collectionSegmentVC


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HexRGB_WSJ(242, 243, 244);
    [self setUp];
    _deleteBarItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(delete)];
    
    _cancelBarItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
   
    [self.navigationItem setRightBarButtonItem:_deleteBarItem];
    
    // Do any additional setup after loading the view.
}

- (void)setUp{
  

    _learnVC = [[BTCouseListVC alloc] initWithType:1];
    _learnVC.title = @"学习资料";
    
    _topicVC = [[BTCouseListVC alloc] initWithType:2];
    _topicVC.title = @"专题";
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    SegmentViewController *vc = [[SegmentViewController alloc]init];
    NSArray *titleArray = @[@"学习资料", @"专题"];
    vc.titleArray = titleArray;
    vc.titleSelectedColor = kMainColor;
    vc.subViewControllers = @[_learnVC, _topicVC];
    vc.buttonHeight = ButtonHeight;
    vc.bottomLineHeight = 4;
    vc.bottomLineColor = kMainColor;
    vc.buttonWidth = MENU_BUTTON_WIDTH;
//    vc.segmentHeaderType = 0;
    [vc initSegment];
    [vc addParentController:self];

   
}

//点击右上角删除按钮
- (void)cancel {
    

    [self.navigationItem setRightBarButtonItem:_deleteBarItem];
    [self.learnVC setIsEdit:NO];
    [self.topicVC setIsEdit:NO];
}

//点击右上角取消按钮
- (void)delete {

    [self.navigationItem setRightBarButtonItem:_cancelBarItem];
    [self.learnVC setIsEdit:YES];
    [self.topicVC setIsEdit:YES];
}


#pragma mark -- YSLContainerViewControllerDelegate
- (void)containerViewItemIndex:(NSInteger)index currentController:(UIViewController *)controller
{


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
